package com.yztc.orangeentertainment.ui.main.subscribefragment.staritem.starwishfragment;

import android.content.Context;

import com.yztc.orangeentertainment.bean.staritembean.WishBean;
import com.yztc.orangeentertainment.bean.staritembean.WishListBean;
import com.yztc.orangeentertainment.config.SubscribeUrlConfig;
import com.yztc.orangeentertainment.http.SubscribeRetrofitService;

import java.util.List;
import java.util.Map;

import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;

/**
 * Created by My on 2016/10/8.
 */
public class WishModle implements WishContract.Modle {
    @Override
    public void getWishAll(String type, Map<String, String> params, final OnLoadWishListener loadWishListener) {
        Retrofit retrofit=new Retrofit.Builder().baseUrl(SubscribeUrlConfig.PATH.BASE_URL).addConverterFactory(GsonConverterFactory.create()).build();
        Call<WishBean> call=retrofit.create(SubscribeRetrofitService.class).getStarWishAll(type,params);
        call.enqueue(new Callback<WishBean>() {
            @Override
            public void onResponse(Call<WishBean> call, Response<WishBean> response) {
                loadWishListener.onSuccess(response.body().getData().getList());
            }

            @Override
            public void onFailure(Call<WishBean> call, Throwable t) {
                loadWishListener.onFailure((Exception) t);
            }
        });
    }
}
